<html>
<head>
<style>
body
{
	font: 10pt helvetica,arial,sans-serif;
	width: 150;
}
</style>
<script>
var BOOKMARKS_URL = 'https://www.google.com/bookmarks/';
var NO_LABEL = 'no_label';
var STATUS_READY = 0;
var STATUS_LOADING = 1;
var STATUS_LOGIN = 2;
var status_tag;
var background_page;

function init()
{
	background_page = chrome.extension.getBackgroundPage();
	status_tag = document.createElement('span');
	document.body.appendChild(status_tag);
	background_page.startImport();
	window.setTimeout(updateStatus, 1);
}

function updateStatus()
{
	var status = background_page.getStatus();
	if (status == STATUS_LOADING)
	{
		status_tag.innerHTML = 'Loading...';
		window.setTimeout(updateStatus, 10);
	}
	else if (status == STATUS_LOGIN)
		status_tag.innerHTML = '<a href="" onclick="gotoBookmarksPage()">Authorisation</a> is required';
	else if (status == STATUS_READY)
		window.close();
	else
		status_tag.innerHTML = 'Error: Wrong status ' + status;
}

function gotoBookmarksPage()
{
	chrome.tabs.create({ url: BOOKMARKS_URL });
}

</script>
</head>
<body onload="init()">
</body>
</html>